home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / util / moni / Scout-src.lha / netinclude / stdio.h < prev    next >
C/C++ Source or Header  |  2002-09-16  |  5KB  |  229 lines

  1. #ifndef STDIO_H
  2. #define STDIO_H \
  3.        "$Id: stdio.h,v 1.1.1.1 2001/11/26 22:21:13 tboeckel Exp $"
  4. /*
  5.  *      Standard ANSI C IO library subset for AmigaOS 2.04 dos.library
  6.  *
  7.  *      Copyright © 1994 AmiTCP/IP Group,
  8.  *                       Network Solutions Development, Inc.
  9.  *                       All rights reserved.
  10.  */
  11.  
  12. #ifndef USE_DOSIO
  13. #include <include:stdio.h>
  14. #else
  15.  
  16. #if defined(__SASC) || defined(__GNUC__)
  17. #ifndef  PROTO_DOS_H
  18. #include <proto/dos.h>
  19. #endif
  20. #else
  21. #ifndef  CLIB_DOS_PROTOS_H
  22. #include <clib/dos_protos.h>
  23. #endif
  24. #endif
  25.  
  26. #ifndef DOS_DOS_H
  27. #include <dos/dos.h>
  28. #endif
  29.  
  30. #ifndef DOS_STDIO_H
  31. #include <dos/stdio.h>
  32. #endif
  33.  
  34. #ifndef _COMMSIZE_H
  35. #include <sys/commsize.h>
  36. #endif
  37.  
  38. #ifndef _COMMLIST_H
  39. #include <sys/commlist.h>
  40. #endif
  41.  
  42. typedef unsigned long fpos_t;
  43.  
  44. #ifndef _COMMNULL_H
  45. #include <sys/commnull.h>
  46. #endif
  47.  
  48. #ifndef DOS_RDARGS_H
  49. #include <dos/rdargs.h>
  50. #endif
  51.  
  52. ULONG VCSPrintf(struct CSource *buf, const char *fmt, va_list ap);
  53. ULONG CSPrintf(struct CSource *buf, const char *fmt, ...);
  54. ULONG VSPrintf(STRPTR, const char *, va_list);
  55. ULONG SPrintf(STRPTR, const char *, ...);
  56.  
  57. #define _IOFBF   BUF_FULL
  58. #define _IONBF   BUF_NONE
  59. #define _IOLBF   BUF_LINE
  60.  
  61. #define BUFSIZ        512
  62. #define EOF        ENDSTREAMCH
  63. #define FOPEN_MAX    20
  64. #define FILENAME_MAX    64
  65. #define L_tmpnam    64
  66.  
  67. #define SEEK_SET OFFSET_BEGINNING    /* Seek from beginning of file */
  68. #define SEEK_CUR OFFSET_CURRENT        /* Seek from current file position */
  69. #define SEEK_END OFFSET_END        /* Seek from end of file */
  70.  
  71. #define TMP_MAX 999             /* Guaranteed unique temp names */
  72.  
  73. typedef long FILE;        /* have to define something */
  74.  
  75. extern BPTR __dosio_files[3];    /* defined in dosio_init.c, autoinitialized */
  76.  
  77. #define stdin  __dosio_files[0]    /* standard input file pointer */
  78. #define stdout __dosio_files[1]    /* standard output file pointer */
  79. #define stderr __dosio_files[2]    /* standard error file pointer */
  80.  
  81. /*
  82.  * Prototypes for ANSI standard functions.
  83.  */
  84.  
  85. #define remove(name) !DeleteFile((STRPTR)(name))
  86.  
  87. #define rename(oldname, newname) !Rename((STRPTR)(oldname), (STRPTR)(newname))
  88.  
  89. #if 0
  90. extern FILE *tmpfile(void);
  91. extern char *tmpnam(char *s);
  92. #endif
  93.  
  94. #define fclose(f) !Close((f))
  95.  
  96. #define fflush(f) ((Flush((f))) ? 0 : EOF)
  97.  
  98. #if 0
  99. extern FILE *fopen(const char *, const char *);
  100. extern FILE *freopen(const char *, const char *, FILE *);
  101.  
  102. extern void setbuf(FILE *, char *);
  103. #endif
  104.  
  105. #define setvbuf(fh, buff, type, size) \
  106.   SetVBuf((fh), (STRPTR)(buff), (type), (size))
  107.  
  108. #define fprintf FPrintf
  109.  
  110. #if 0
  111. extern int fscanf(FILE *, const char *, ...);
  112. #endif
  113.  
  114. #define printf Printf
  115.  
  116. #if 0
  117. extern int scanf(const char *, ...);
  118. #endif
  119.  
  120. /* this is from net.lib, not from dos.library */
  121. #define sprintf SPrintf
  122.  
  123. #if 0
  124. extern int sscanf(const char *, const char *, ...);
  125. #endif
  126.  
  127. #define vfprintf VFPrintf
  128. #define vprintf VPrintf
  129.  
  130. /* this is from net.lib, not from dos.library */
  131. #define vsprintf VSPrintf
  132.  
  133. #define fgetc FGetC
  134.  
  135. #define fgets(buf, len, fh) FGets((fh), (buf), (len))
  136.  
  137. #define fputc(c, fh) FPutC((fh), (c))
  138.  
  139. #define fputs(str, fh) FPuts((fh), (STRPTR)(str))
  140.  
  141. #define getc fgetc
  142.  
  143. #define getchar() getc(stdin)
  144.  
  145. #define gets(buf) fgets((buf), 1024, stdin) /* length is a kludge */
  146.  
  147. #define putc fputc
  148.  
  149. #define putchar(c) putc((c),stdout)
  150.  
  151. #define puts(str) fputs((str), stdout)
  152.  
  153. #define ungetc(c, fh) UnGetC((fh), (c))
  154.  
  155. #define fread(buf, blocklen, blocks, fh) \
  156.   FRead((fh), (APTR)(buf), (blocklen), (blocks))
  157.  
  158. #define fwrite(buf, blocklen, blocks, fh) \
  159.   FWrite((fh), (APTR)(buf), (blocklen), (blocks))
  160.  
  161. #define fgetpos(fh, fposp) (*(fposp) = Seek((fh), 0L, OFFSET_CURRENT), \
  162.                 (*(fposp) == (-1)))
  163.  
  164. #define fseek Seek
  165.  
  166. #define fsetpos(fh, fposp) \
  167.   ((Seek((fh), *(fposp), OFFSET_BEGINNING) == -1) ? EOF : 0)
  168.  
  169. #define ftell(fh) Seek((fh), 0L, OFFSET_CURRENT)
  170.  
  171. #define rewind(fh) (void)Seek((fh), 0L, OFFSET_BEGINNING)
  172.  
  173. #if 0
  174. #define clearerr(fh) SetIoErr(0L) /* not exact */
  175. #endif
  176.  
  177. #if 0
  178. extern int feof(FILE *);
  179. #define feof(p) (((p)->_flag & _IOEOF) != 0)
  180. #endif
  181.  
  182. #if 0
  183. #define ferror(fh) (IoErr() != 0) /* not exact */
  184. #endif
  185.  
  186. /* this is in net.lib */
  187. extern void perror(const char *);
  188.  
  189. #ifndef _STRICT_ANSI
  190.  
  191. /* defines for mode of access() */
  192. #define R_OK 4
  193. #define W_OK 2
  194. #define X_OK 1
  195. #define F_OK 0
  196.  
  197. /*
  198.  * Prototypes for Non-ANSI functions.
  199.  */
  200.  
  201. extern int __io2errno(int);
  202.  
  203. #define fgetchar() fgetc(stdin)
  204.  
  205. #define fputchar(c) fputc((c), stdout)
  206.  
  207. #define setnbf(fh) (void)SetVBuf((fh), NULL, BUF_NONE, -1)
  208.  
  209. extern int __access(const char *, int);
  210. extern int access(const char *, int);
  211. extern int chdir(const char *);
  212. extern int chmod(const char *, int);
  213. extern char *getcwd(char *, int);
  214.  
  215. /* extern int unlink(const char *); in fcntl.h*/
  216.  
  217. #define  clrerr  clearerr
  218. #define  access  __access
  219.  
  220. #endif /* _STRICT_ANSI */
  221.  
  222. #if 0
  223. extern unsigned long __fmask;
  224. extern int __fmode;
  225. #endif
  226.  
  227. #endif /* USE_DOSIO */
  228. #endif /* STDIO_H */
  229.